WIP: CPU network SoA dual-write (not for merge) - #3822
Draft
nrnhines wants to merge 20 commits into
Draft
Conversation
Documents the decision to pause GPU network buffers until CPU network SoA adoption. Provides agent rules, session starting prompt, and Phase 0 design checklist for local/cpu-network-soa branched from master.
Expand doc/network-soa-phase0.md into the authoritative field-tag, handle, thread-slice, sidecar, and invalidation spec. Add neuron::container::network PointProcess and Weight soa storages on Model (Node-style handles), wire find_container_info/unsorted callbacks, and unit-test that handles survive permutation.
Add §5.4.1 (target_/src_ as indices/handles, not data_handle) and §5.5.1 (InputPreSyn deferred; thin gid→fanout after cpu-net-soa).
Embed PointProcess::owning_handle on Point_process and sync Instance/ MechType/ThreadId when prop or _vnt changes. NetCon allocates parallel Weight SoA rows (heap weight_ stays delivery primary). Unit tests cover dual-write helpers and PP shell lifetime.
Add network::NetCon storage (Target, WeightIndex, WeightCount, Delay, Active, SrcPreSyn) on Model. NetCon owns an SoA row and syncs fields on create/update. HOC weight() steers into Weight SoA data_handles; deliver mirrors SoA↔heap around pnt_receive so NET_RECEIVE still sees double*.
Add network::PreSyn storage on Model and embed owning handles on PreSyn. Rebuild a global NetCon* fanout order from dil_ (CoreNEURON-shaped ranges); send/deliver/fanout iterate that order with dil_ fallback. NetCon::SrcPreSyn points at the source PreSyn SoA row.
SelfEvent records Weight SoA base index and PointProcess row; net_send resolves index from NetCon. Delivery uses nrn_pnt_receive_by_weight_index (M2: SoA→heap→MOD pnt_receive→heap→SoA). NetCon::deliver shares that path.
…ght wipe Document Phases 0–4 status and known gaps in GROK-NETWORK-SOA.md. Rebuild PreSyn fanout at NetCvode::init_events (not only on first spike). Stop soa_sync from copying heap weights over SoA (HOC weight writes). Add pytest/ctest network_soa_delivery gate for NetStim→ExpSyn.
MOD/nrnivmodl builds only see build/include. Embedding PointProcess owning_handle forced network/model_data headers that are not installed there, breaking demo release compiles. Store a non-owning _soa_id on Point_process; own the SoA row via a map in point.cpp. Add point_process_access.hpp / nrn_point_process_soa_row for library code.
HOC weight[] is SoA-primary; pnt_receive_init and FOR_NETCONS mutate the heap. Sync SoA↔heap around INITIAL, and for FOR_NETCONS targets sync all NetCons sharing the target (including WatchCondition flag delivery). Fixes hoctests::test_netrec_init_py and external_nrntest FOR_NETCONS/stdp1.
…eliver Include PointProcess, Weight, NetCon, and PreSyn containers in nrn_ensure_model_data_are_sorted (thread partition, weight-block repack, fanout rebuild, cache offsets). On NetCon deliver without FOR_NETCONS, pass a temporary buffer into pnt_receive instead of the long-lived weight_ heap so SoA stays the source of truth while the heap remains for SaveState and FOR_NETCONS.
Save NetCon weights from Weight SoA (HOC-primary) and restore into both heap and SoA so materialize-on-deliver matches SaveState. Resolve SelfEvent ownership via NetCon object index and weight_index2netcon when the heap pointer is absent; index2netcon maps all NetCons by HOC index.
Materialize Weight SoA into the heap before BBSaveState weight IO and mirror heap back to SoA after restore. Match SelfEvents to target NetCons by heap base or weight_index, and rebind both fields from the DEList ncindex on restore (same dual-write policy as SaveState).
sort_network_data must resolve HOC point-process objects via ob2pntproc_0 (dataspace), not this_pointer. NetCon deliver must pass the long-lived weight_ heap into pnt_receive so MOD net_send(..., _w) preserves SelfEvent identity for SaveState; resolve owner by weight_index when needed. Softens SelfEvent savestate_write when no NetCon is found.
Add doc/network-soa/ with L0 README, topology (fanout authority, CoreNEURON mapping), dual-write/heap roadmap, and sort packing. Point GROK handoff at the layered map and correct stale short-lived-materialize status text.
| WHEN("A random reverse-permutation is applied") { | ||
| std::vector<std::size_t> perm(n); | ||
| std::iota(perm.begin(), perm.end(), 0); | ||
| std::mt19937 g{42}; |
| std::vector<std::size_t> perm(n); | ||
| std::iota(perm.begin(), perm.end(), 0); | ||
| std::mt19937 g{42}; | ||
| std::shuffle(perm.begin(), perm.end(), g); |
Contributor
|
✔️ 415a51f -> artifacts URL |
|
✔️ 415a51f -> Azure artifacts URL |
Sync Weight SoA when exporting NetCon weights to CoreNEURON and when returning weights after a CoreNEURON run (HOC weight[] is SoA-primary). Apply black/clang-format line-wrap fixes for network SoA tests. Merge with master already on branch for formatting toolchain updates.
|
✔️ d8911a3 -> Azure artifacts URL |
Contributor
|
✔️ d8911a3 -> artifacts URL |
SelfEvent from mech INITIAL often has nullptr weight; still route through nrn_pnt_receive_by_weight_index so FOR_NETCONS heap mutations sync to SoA. Apply ninja format-pr clang-format fixes for network SoA sources.
|
✔️ 15b4db3 -> Azure artifacts URL |
Contributor
|
✔️ 15b4db3 -> artifacts URL |
ASan CI: nrn_point_process_soa_sync during free_one_point/relocate read freed Prop or dangling state. Stop syncing on free (SoA row released in ~Point_process); harden sync to verify prop still owns this pnt and that _vnt is a live NrnThread. NetCon factory wrote magnitude only to weight_ heap; HOC weight[] reads SoA and init_events soa_to_heap wiped the value (0.0 != 0.1). Mirror magnitude into Weight SoA after construction.
|
✔️ d55851a -> Azure artifacts URL |
Contributor
|
✔️ d55851a -> artifacts URL |
Do not invent a short-lived weight buffer when weight_index < 0 (flag-only / INITIAL net_send); MOD may net_send that pointer and corrupt later queue / BBSaveState handling. Skip NET_RECEIVE INITIAL for NetCons whose target Prop is already freed.
|
|
✔️ 77297b9 -> Azure artifacts URL |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3822 +/- ##
==========================================
+ Coverage 68.48% 68.62% +0.14%
==========================================
Files 691 700 +9
Lines 111413 112418 +1005
==========================================
+ Hits 76301 77151 +850
- Misses 35112 35267 +155 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
✔️ 77297b9 -> artifacts URL |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Status: Work in progress — do not merge to master
Exploratory stack for CoreNEURON-shaped network data on the NEURON CPU side. Intended as a durable review/reference branch, not a landable feature PR.
Planned follow-on branch (later):
hines-grok/cpu-net-soa-heap-free(or similar), forked from this work after dual-write+sort, to drop long-livedNetCon::weight_under a defined ABI plan.GPU native (later, undetermined order relative to master): spike queue + threshold → net_send buffer on GPU; NET_RECEIVE
net_sendon GPU; ARTIFICIAL_CELLnet_sendstays CPU; distribute via net_receive buffer. Whether heap-free lands on master before that GPU track is undecided.What this PR contains
weight_indexnrn_ensure_model_data_are_sorted(thread packing, weight-block contiguity, fanout rebuild)doc/network-soa/(topology, heap policy, sort) +GROK-NETWORK-SOA.md+doc/network-soa-phase0.mdExplicitly not in this PR
NetCon::weight_(nocmodl still needs long-lived MOD scratch fornet_send(..., _w)/ FOR_NETCONS / INITIAL)Docs for reviewers
Start at
doc/network-soa/README.md.Test plan
ctest -j 8on author machine (post-regression fixes)